package mythesis.gui.main.components;
import mythesis.gui.main.components.api.TileLine;
import mythesis.gui.main.components.api.Tile;
import mythesis.tiles.character.*;
import mythesis.tiles.variable.*;
import javafx.scene.*;
import javafx.scene.shape.*;
import javafx.scene.paint.*;
import javafx.scene.text.*;
import javafx.scene.input.*;


public class EditorPanel extends CustomNode
{
    public var barOffsetY = 0.0;
    public var barOffsetYPct = 0.0;
    public var numberOfLines = 500;
	public var lineClick = -1;
    public var page = 0;
    public var isDragging = false;
    public var isScrolling = false;
    public var clickedWindow = false;
    var didClickTile = false;
    
    public var eventList:String[] = [
    								"GameStarted",
    								"DecidingOnMovement",
    								"MakingASuggestionOrAccusation",
    								"ListeningToSuggestion",
    								"DisprovingSuggestion"
    							    ];
    
    public var listGameStarted = Group{
	    translateX	: 50
	    translateY	: bind 10 - (20*numberOfLines*barOffsetYPct) +410*barOffsetYPct;
	    onMousePressed: function (e:MouseEvent):Void{
			didClickTile = true;	        
	    }
	    onMouseExited: function (e:MouseEvent):Void{
	        didClickTile = false;
	    }
    };
    public var listDecidingOnMovement = Group
    {
	    translateX	: 50
	    translateY	: bind 10 - (20*numberOfLines*barOffsetYPct) +410*barOffsetYPct;
	    onMousePressed: function (e:MouseEvent):Void{
			didClickTile = true;	        
	    }
	    onMouseExited: function (e:MouseEvent):Void{
	        didClickTile = false;
	    }        
    };
    public var listMakingASuggestionOrAccusation = Group
    {
	    translateX	: 50
	    translateY	: bind 10 - (20*numberOfLines*barOffsetYPct) +410*barOffsetYPct;
	    onMousePressed: function (e:MouseEvent):Void{
			didClickTile = true;	        
	    }
	    onMouseExited: function (e:MouseEvent):Void{
	        didClickTile = false;
	    }
    };
    public var listListeningToSuggestion = Group
    {
	    translateX	: 50
	    translateY	: bind 10 - (20*numberOfLines*barOffsetYPct) +410*barOffsetYPct;
	    onMousePressed: function (e:MouseEvent):Void{
			didClickTile = true;	        
	    }
	    onMouseExited: function (e:MouseEvent):Void{
	        didClickTile = false;
	    }
    };
    public var listDisprovingSuggestion = Group
    {
	    translateX	: 50
	    translateY	: bind 10 - (20*numberOfLines*barOffsetYPct) +410*barOffsetYPct;
	    onMousePressed: function (e:MouseEvent):Void{
			didClickTile = true;	        
	    }
	    onMouseExited: function (e:MouseEvent):Void{
	        didClickTile = false;
	    }
    };
    
	public var listAll:Group[] = [
       	listGameStarted,
       	listDecidingOnMovement,
       	listMakingASuggestionOrAccusation,
       	listListeningToSuggestion,
       	listDisprovingSuggestion
	];	
	
	public function deleteAllTiles():String
	{
	    for (i in [0..listAll.size()-1])
	    {
	   		while (listAll[i].content.size() > 0)
	   		{
	   		    delete listAll[i].content[0];
	   		}
	   		//println(" page{i} size:  {listAll[i].content.size()}");
	    }
	    
	    return "Successfully deleted all tiles.";
	}
	
	public function getArgText(line:Integer, arg:Integer):String
	{
	   
	   for (i in [0..listAll[page].content.size()])
	   {
			if (listAll[page].content[i] instanceof GoTo)
			{
			    if ({listAll[page].content[i] as GoTo}.line == line )
			    {
			        return {listAll[page].content[i] as GoTo}.args[arg];
			    }
			}
			if (listAll[page].content[i] instanceof Suggest)
			{
			    if ({listAll[page].content[i] as Suggest}.line == line )
			    {
			        return {listAll[page].content[i] as Suggest}.args[arg];
			    }
			}
			if (listAll[page].content[i] instanceof Accuse)
			{
			    if ({listAll[page].content[i] as Accuse}.line == line )
			    {
			        return {listAll[page].content[i] as Accuse}.args[arg];
			    }
			}
			if (listAll[page].content[i] instanceof Increase)
			{
			    if ({listAll[page].content[i] as Increase}.line == line )
			    {
			        return {listAll[page].content[i] as Increase}.args[arg];
			    }
			}
			if (listAll[page].content[i] instanceof Decrease)
			{
			    if ({listAll[page].content[i] as Decrease}.line == line )
			    {
			        return {listAll[page].content[i] as Decrease}.args[arg];
			    }
			}
			if (listAll[page].content[i] instanceof Multiply)
			{
			    if ({listAll[page].content[i] as Multiply}.line == line )
			    {
			        return {listAll[page].content[i] as Multiply}.args[arg];
			    }
			}
			if (listAll[page].content[i] instanceof Divide)
			{
			    if ({listAll[page].content[i] as Divide}.line == line )
			    {
			        return {listAll[page].content[i] as Divide}.args[arg];
			    }
			}
			if (listAll[page].content[i] instanceof Raise)
			{
			    if ({listAll[page].content[i] as Raise}.line == line )
			    {
			        return {listAll[page].content[i] as Raise}.args[arg];
			    }
			}
			if (listAll[page].content[i] instanceof Testify)
			{
			    if ({listAll[page].content[i] as Testify}.line == line )
			    {
			        return {listAll[page].content[i] as Testify}.args[arg];
			    }
			}
			if (listAll[page].content[i] instanceof Falsify)
			{
			    if ({listAll[page].content[i] as Falsify}.line == line )
			    {
			        return {listAll[page].content[i] as Falsify}.args[arg];
			    }
			}
			if (listAll[page].content[i] instanceof Note)
			{
			    if ({listAll[page].content[i] as Note}.line == line )
			    {
			        return {listAll[page].content[i] as Note}.args[arg];
			    }
			}
			if (listAll[page].content[i] instanceof If)
			{
			    if ({listAll[page].content[i] as If}.line == line )
			    {
			        return {listAll[page].content[i] as If}.args[arg];
			    }
			}
			if (listAll[page].content[i] instanceof While)
			{
			    if ({listAll[page].content[i] as While}.line == line )
			    {
			        return {listAll[page].content[i] as While}.args[arg];
			    }
			}
			if (listAll[page].content[i] instanceof Set)
			{
			    if ({listAll[page].content[i] as Set}.line == line )
			    {
			        return {listAll[page].content[i] as Set}.args[arg];
			    }
			}
			if (listAll[page].content[i] instanceof EndCondition)
			{
			    if ({listAll[page].content[i] as EndCondition}.line == line )
			    {
			        return {listAll[page].content[i] as EndCondition}.args[arg];
			    }
			}
			if (listAll[page].content[i] instanceof BreakCondition)
			{
			    if ({listAll[page].content[i] as BreakCondition}.line == line )
			    {
			        return {listAll[page].content[i] as BreakCondition}.args[arg];
			    }
			}
			if (listAll[page].content[i] instanceof ListenToSuggestion)
			{
			    if ({listAll[page].content[i] as ListenToSuggestion}.line == line )
			    {
			        return {listAll[page].content[i] as ListenToSuggestion}.args[arg];
			    }
			}
			if (listAll[page].content[i] instanceof DisproveSuggestionWith)
			{
			    if ({listAll[page].content[i] as DisproveSuggestionWith}.line == line )
			    {
			        return {listAll[page].content[i] as DisproveSuggestionWith}.args[arg];
			    }
			}

	   }
	   return "";
	}
	
	public function updateArgText(line:Integer, arg:Integer, text:String, type:String, dValue:String, dText:String)
	{
	   //println(" > {dText}");
	   var dataType:Number;
	   if (type == "Number"){ dataType = 1; }
	   if (type == "Word"){ dataType = 2; }
	   if (type == "Truth"){ dataType = 3; }
	   if (type == "Special"){ dataType = 4; }
	   
	   var dataValue:Number;
	   if (dValue == "1"){ dataValue = 1; }
	   if (dValue == "2"){ dataValue = 2; }
	   if (dValue == "3"){ dataValue = 3; }
	   
	   for (i in [0..listAll[page].content.size()])
	   {
			if (listAll[page].content[i] instanceof GoTo)
			{
			    if ({listAll[page].content[i] as GoTo}.line == line )
			    {
			        {listAll[page].content[i] as GoTo}.args[arg] = dText;
			        {listAll[page].content[i] as GoTo}.argClick = -1;
			        {listAll[page].content[i] as GoTo}.setDataType(arg, dataType);
			        {listAll[page].content[i] as GoTo}.setDataValue(arg, dataValue);
			    }
			}
	        if (listAll[page].content[i] instanceof Suggest)
			{
			    if ({listAll[page].content[i] as Suggest}.line == line )
			    {
			        {listAll[page].content[i] as Suggest}.args[arg] = dText;
			        {listAll[page].content[i] as Suggest}.argClick = -1;
			        {listAll[page].content[i] as Suggest}.setDataType(arg, dataType);
			        {listAll[page].content[i] as Suggest}.setDataValue(arg, dataValue);
			    }
			}
			if (listAll[page].content[i] instanceof Accuse)
			{
			    if ({listAll[page].content[i] as Accuse}.line == line )
			    {
			        {listAll[page].content[i] as Accuse}.args[arg] = dText;
			        {listAll[page].content[i] as Accuse}.argClick = -1;
			        {listAll[page].content[i] as Accuse}.setDataType(arg, dataType);
			        {listAll[page].content[i] as Accuse}.setDataValue(arg, dataValue);
			    }
			}
			else if (listAll[page].content[i] instanceof Increase)
			{
			    if ({listAll[page].content[i] as Increase}.line == line )
			    {
			        {listAll[page].content[i] as Increase}.args[arg] = dText;
			        {listAll[page].content[i] as Increase}.argClick = -1;
			        {listAll[page].content[i] as Increase}.setDataType(arg, dataType);
			        {listAll[page].content[i] as Increase}.setDataValue(arg, dataValue);
			    }
			}
			else if (listAll[page].content[i] instanceof Decrease)
			{
			    if ({listAll[page].content[i] as Decrease}.line == line )
			    {
			        {listAll[page].content[i] as Decrease}.args[arg] = dText;
			        {listAll[page].content[i] as Decrease}.argClick = -1;
			        {listAll[page].content[i] as Decrease}.setDataType(arg, dataType);
			        {listAll[page].content[i] as Decrease}.setDataValue(arg, dataValue);
			    }
			}
			else if (listAll[page].content[i] instanceof Multiply)
			{
			    if ({listAll[page].content[i] as Multiply}.line == line )
			    {
			        {listAll[page].content[i] as Multiply}.args[arg] = dText;
			        {listAll[page].content[i] as Multiply}.argClick = -1;
			        {listAll[page].content[i] as Multiply}.setDataType(arg, dataType);
			        {listAll[page].content[i] as Multiply}.setDataValue(arg, dataValue);
			    }
			}
			else if (listAll[page].content[i] instanceof Divide)
			{
			    if ({listAll[page].content[i] as Divide}.line == line )
			    {
			        {listAll[page].content[i] as Divide}.args[arg] = dText;
			        {listAll[page].content[i] as Divide}.argClick = -1;
			        {listAll[page].content[i] as Divide}.setDataType(arg, dataType);
			        {listAll[page].content[i] as Divide}.setDataValue(arg, dataValue);
			    }
			}
			else if (listAll[page].content[i] instanceof Raise)
			{
			    if ({listAll[page].content[i] as Raise}.line == line )
			    {
			        {listAll[page].content[i] as Raise}.args[arg] = dText;
			        {listAll[page].content[i] as Raise}.argClick = -1;
			        {listAll[page].content[i] as Raise}.setDataType(arg, dataType);
			        {listAll[page].content[i] as Raise}.setDataValue(arg, dataValue);
			    }
			}
			else if (listAll[page].content[i] instanceof Testify)
			{
			    if ({listAll[page].content[i] as Testify}.line == line )
			    {
			        {listAll[page].content[i] as Testify}.args[arg] = dText;
			        {listAll[page].content[i] as Testify}.argClick = -1;
			        {listAll[page].content[i] as Testify}.setDataType(arg, dataType);
			        {listAll[page].content[i] as Testify}.setDataValue(arg, dataValue);
			    }
			}
			else if (listAll[page].content[i] instanceof Falsify)
			{
			    if ({listAll[page].content[i] as Falsify}.line == line )
			    {
			        {listAll[page].content[i] as Falsify}.args[arg] = dText;
			        {listAll[page].content[i] as Falsify}.argClick = -1;
			        {listAll[page].content[i] as Falsify}.setDataType(arg, dataType);
			        {listAll[page].content[i] as Falsify}.setDataValue(arg, dataValue);
			    }
			}
			else if (listAll[page].content[i] instanceof Note)
			{
			    if ({listAll[page].content[i] as Note}.line == line )
			    {
			        {listAll[page].content[i] as Note}.args[arg] = dText;
			        {listAll[page].content[i] as Note}.argClick = -1;
			        {listAll[page].content[i] as Note}.setDataType(arg, dataType);
			        {listAll[page].content[i] as Note}.setDataValue(arg, dataValue);
			    }
			}
			else if (listAll[page].content[i] instanceof If)
			{
			    if ({listAll[page].content[i] as If}.line == line )
			    {
			        {listAll[page].content[i] as If}.args[arg] = dText;
			        {listAll[page].content[i] as If}.argClick = -1;
			        {listAll[page].content[i] as If}.setDataType(arg, dataType);
			        {listAll[page].content[i] as If}.setDataValue(arg, dataValue);
			    }
			}
			else if (listAll[page].content[i] instanceof While)
			{
			    if ({listAll[page].content[i] as While}.line == line )
			    {
			        {listAll[page].content[i] as While}.args[arg] = dText;
			        {listAll[page].content[i] as While}.argClick = -1;
			        {listAll[page].content[i] as While}.setDataType(arg, dataType);
			        {listAll[page].content[i] as While}.setDataValue(arg, dataValue);
			    }
			}
			else if (listAll[page].content[i] instanceof Set)
			{
			    if ({listAll[page].content[i] as Set}.line == line )
			    {
			        {listAll[page].content[i] as Set}.args[arg] = dText;
			        {listAll[page].content[i] as Set}.argClick = -1;
			        {listAll[page].content[i] as Set}.setDataType(arg, dataType);
			        {listAll[page].content[i] as Set}.setDataValue(arg, dataValue);
			    }
			}
			else if (listAll[page].content[i] instanceof DisproveSuggestionWith)
			{
			    if ({listAll[page].content[i] as DisproveSuggestionWith}.line == line )
			    {
			        {listAll[page].content[i] as DisproveSuggestionWith}.args[arg] = dText;
			        {listAll[page].content[i] as DisproveSuggestionWith}.argClick = -1;
			        {listAll[page].content[i] as DisproveSuggestionWith}.setDataType(arg, dataType);
			        {listAll[page].content[i] as DisproveSuggestionWith}.setDataValue(arg, dataValue);
			    }
			}
	   }
	}
	
	public function setNumArgClicked(num:Integer)
	{
	    for (i in [0..listAll[page].content.size()])
	    {
	        //if (listAll[page].content[i] instanceof RollDice){ 		if ( { listAll[page].content[i] as RollDice}.line 		== lineClick ){  }}
	        //if (listAll[page].content[i] instanceof TakeShortcut){ 	if ( { listAll[page].content[i] as TakeShortcut}.line	== lineClick ){ used = true; }}
	        if (listAll[page].content[i] instanceof Suggest){ 		if ( { listAll[page].content[i] as Suggest}.line 		== lineClick ){ {listAll[page].content[i] as Suggest}.argClick = num; }}
	        if (listAll[page].content[i] instanceof Accuse){ 		if ( { listAll[page].content[i] as Accuse}.line 		== lineClick ){ {listAll[page].content[i] as Accuse}.argClick = num; }}
	        if (listAll[page].content[i] instanceof GoTo){ 			if ( { listAll[page].content[i] as GoTo}.line 			== lineClick ){ {listAll[page].content[i] as GoTo}.argClick = num; }}
	        if (listAll[page].content[i] instanceof Note){ 			if ( { listAll[page].content[i] as Note}.line 			== lineClick ){ {listAll[page].content[i] as Note}.argClick = num; }}
	        if (listAll[page].content[i] instanceof Increase){ 		if ( { listAll[page].content[i] as Increase}.line 		== lineClick ){ {listAll[page].content[i] as Increase}.argClick = num; }}
	        if (listAll[page].content[i] instanceof Decrease){ 		if ( { listAll[page].content[i] as Decrease}.line 		== lineClick ){ {listAll[page].content[i] as Decrease}.argClick = num; }}
	        if (listAll[page].content[i] instanceof Multiply){ 		if ( { listAll[page].content[i] as Multiply}.line 		== lineClick ){ {listAll[page].content[i] as Multiply}.argClick = num; }}
	        if (listAll[page].content[i] instanceof Divide){ 		if ( { listAll[page].content[i] as Divide}.line 		== lineClick ){ {listAll[page].content[i] as Divide}.argClick = num; }}
	        if (listAll[page].content[i] instanceof Raise){ 		if ( { listAll[page].content[i] as Raise}.line 			== lineClick ){ {listAll[page].content[i] as Raise}.argClick = num; }}
	        if (listAll[page].content[i] instanceof Testify){ 		if ( { listAll[page].content[i] as Testify}.line 		== lineClick ){ {listAll[page].content[i] as Testify}.argClick = num; }}
	        if (listAll[page].content[i] instanceof Falsify){ 		if ( { listAll[page].content[i] as Falsify}.line 		== lineClick ){ {listAll[page].content[i] as Falsify}.argClick = num; }}
	        if (listAll[page].content[i] instanceof If){ 			if ( { listAll[page].content[i] as If}.line 			== lineClick ){ {listAll[page].content[i] as If}.argClick = num; }}
	        if (listAll[page].content[i] instanceof While){ 		if ( { listAll[page].content[i] as While}.line 			== lineClick ){ {listAll[page].content[i] as While}.argClick = num; }}
	        if (listAll[page].content[i] instanceof DisproveSuggestionWith){ 		if ( { listAll[page].content[i] as DisproveSuggestionWith}.line 			== lineClick ){ {listAll[page].content[i] as DisproveSuggestionWith}.argClick = num; }}
	        
	    }
	}
	
	
	public function numArgClicked():Integer
	{
	    var ret = -1;
	    for (i in [0..listAll[page].content.size()])
	    {
	        //if (listAll[page].content[i] instanceof RollDice){ 		if ( { listAll[page].content[i] as RollDice}.line 		== lineClick ){  }}
	        //if (listAll[page].content[i] instanceof TakeShortcut){ 	if ( { listAll[page].content[i] as TakeShortcut}.line	== lineClick ){ used = true; }}
	        if (listAll[page].content[i] instanceof Suggest){ 		if ( { listAll[page].content[i] as Suggest}.line 		== lineClick ){ ret = { listAll[page].content[i] as Suggest}.argClick; }}
	        if (listAll[page].content[i] instanceof Accuse){ 		if ( { listAll[page].content[i] as Accuse}.line 		== lineClick ){ ret = { listAll[page].content[i] as Accuse}.argClick; }}
	        if (listAll[page].content[i] instanceof GoTo){ 			if ( { listAll[page].content[i] as GoTo}.line 			== lineClick ){ ret = { listAll[page].content[i] as GoTo}.argClick; }}
	        if (listAll[page].content[i] instanceof Note){ 			if ( { listAll[page].content[i] as Note}.line 			== lineClick ){ ret = { listAll[page].content[i] as Note}.argClick; }}
	        if (listAll[page].content[i] instanceof Increase){ 		if ( { listAll[page].content[i] as Increase}.line 		== lineClick ){ ret = { listAll[page].content[i] as Increase}.argClick; }}
	        if (listAll[page].content[i] instanceof Decrease){ 		if ( { listAll[page].content[i] as Decrease}.line 		== lineClick ){ ret = { listAll[page].content[i] as Decrease}.argClick; }}
	        if (listAll[page].content[i] instanceof Multiply){ 		if ( { listAll[page].content[i] as Multiply}.line 		== lineClick ){ ret = { listAll[page].content[i] as Multiply}.argClick; }}
	        if (listAll[page].content[i] instanceof Divide){ 		if ( { listAll[page].content[i] as Divide}.line 		== lineClick ){ ret = { listAll[page].content[i] as Divide}.argClick; }}
	        if (listAll[page].content[i] instanceof Raise){ 		if ( { listAll[page].content[i] as Raise}.line 			== lineClick ){ ret = { listAll[page].content[i] as Raise}.argClick; }}
	        if (listAll[page].content[i] instanceof Testify){ 		if ( { listAll[page].content[i] as Testify}.line 		== lineClick ){ ret = { listAll[page].content[i] as Testify}.argClick; }}
	        if (listAll[page].content[i] instanceof Falsify){ 		if ( { listAll[page].content[i] as Falsify}.line 		== lineClick ){ ret = { listAll[page].content[i] as Falsify}.argClick; }}
	        if (listAll[page].content[i] instanceof If){ 			if ( { listAll[page].content[i] as If}.line 			== lineClick ){ ret = { listAll[page].content[i] as If}.argClick; }}
	        if (listAll[page].content[i] instanceof While){ 		if ( { listAll[page].content[i] as While}.line 			== lineClick ){ ret = { listAll[page].content[i] as While}.argClick; }}
	        if (listAll[page].content[i] instanceof Set){ 			if ( { listAll[page].content[i] as Set}.line 			== lineClick ){ ret = { listAll[page].content[i] as Set}.argClick; }}
	        if (listAll[page].content[i] instanceof EndCondition){	if ( { listAll[page].content[i] as EndCondition}.line 	== lineClick ){ ret = { listAll[page].content[i] as EndCondition}.argClick; }}
	        if (listAll[page].content[i] instanceof BreakCondition){if ( { listAll[page].content[i] as BreakCondition}.line == lineClick ){ ret = { listAll[page].content[i] as BreakCondition}.argClick; }}
	        if (listAll[page].content[i] instanceof DisproveSuggestionWith){if ( { listAll[page].content[i] as DisproveSuggestionWith}.line == lineClick ){ ret = { listAll[page].content[i] as DisproveSuggestionWith}.argClick; }}
	    }
	    return ret;
	}
	
	public function areCondEndTilesEqual(inPage:Integer):Boolean
	{
	    var countCond = 0;
	    var countEnd  = 0;
	    for (i in [0..listAll[inPage].content.size()-1])
	    {
	        if (listAll[inPage].content[i] instanceof If or listAll[inPage].content[i] instanceof While)
	        {
	            countCond++;
	        }
	        else if (listAll[inPage].content[i] instanceof EndCondition)
	        {
	            countEnd++;
	        }
	    }
	    if (countCond == countEnd){ return true;  }
	    else                      { return false; }
	}
	
	public function areAllFieldsFull(inPage:Integer):Boolean
	{
	    var yes = true;
	    for (i in [0..listAll[inPage].content.size()-1])
	    {
	        if (listAll[inPage].content[i] instanceof Accuse){
	            
		        for (j in [0..{listAll[inPage].content[i] as Accuse}.args.size()-1])
		        {
		            if({listAll[inPage].content[i] as Accuse}.args[j] == "")
		            {
		          		return false;
		           	}
		        }
	        }
	        else if (listAll[inPage].content[i] instanceof DisproveSuggestionWith){
		        for (j in [0..{listAll[inPage].content[i] as DisproveSuggestionWith}.args.size()-1])
		        {
		            if({listAll[inPage].content[i] as DisproveSuggestionWith}.args[j] == "")
		            {
		          		return false;
		           	}
		        }
	        }
	        else if (listAll[inPage].content[i] instanceof GoTo){
		        for (j in [0..{listAll[inPage].content[i] as GoTo}.args.size()-1])
		        {
		            if({listAll[inPage].content[i] as GoTo}.args[j] == "")
		            {
		          		return false;
		           	}
		        }
	        }
	        else if (listAll[inPage].content[i] instanceof Suggest){
		        for (j in [0..{listAll[inPage].content[i] as Suggest}.args.size()-1])
		        {
		            if({listAll[inPage].content[i] as Suggest}.args[j] == "")
		            {
		          		return false;
		           	}
		        }
	        }
	        else if (listAll[inPage].content[i] instanceof Decrease){
		        for (j in [0..{listAll[inPage].content[i] as Decrease}.args.size()-1])
		        {
		            if({listAll[inPage].content[i] as Decrease}.args[j] == "")
		            {
		          		return false;
		           	}
		        }
	        }
	        else if (listAll[inPage].content[i] instanceof Divide){
		        for (j in [0..{listAll[inPage].content[i] as Divide}.args.size()-1])
		        {
		            if({listAll[inPage].content[i] as Divide}.args[j] == "")
		            {
		          		return false;
		           	}
		        }
	        }
	        else if (listAll[inPage].content[i] instanceof Falsify){
		        for (j in [0..{listAll[inPage].content[i] as Falsify}.args.size()-1])
		        {
		            if({listAll[inPage].content[i] as Falsify}.args[j] == "")
		            {
		          		return false;
		           	}
		        }
	        }
	        else if (listAll[inPage].content[i] instanceof If){
		        for (j in [0..{listAll[inPage].content[i] as If}.args.size()-1])
		        {
		            if({listAll[inPage].content[i] as If}.args[j] == "")
		            {
		          		return false;
		           	}
		        }
	        }
	        else if (listAll[inPage].content[i] instanceof Increase){
		        for (j in [0..{listAll[inPage].content[i] as Increase}.args.size()-1])
		        {
		            if({listAll[inPage].content[i] as Increase}.args[j] == "")
		            {
		          		return false;
		           	}
		        }
	        }
	        else if (listAll[inPage].content[i] instanceof Multiply){
		        for (j in [0..{listAll[inPage].content[i] as Multiply}.args.size()-1])
		        {
		            if({listAll[inPage].content[i] as Multiply}.args[j] == "")
		            {
		          		return false;
		           	}
		        }
	        }
	        else if (listAll[inPage].content[i] instanceof Note){
		        for (j in [0..{listAll[inPage].content[i] as Note}.args.size()-1])
		        {
		            if({listAll[inPage].content[i] as Note}.args[j] == "")
		            {
		          		return false;
		           	}
		        }
	        }
	        else if (listAll[inPage].content[i] instanceof Raise){
		        for (j in [0..{listAll[inPage].content[i] as Raise}.args.size()-1])
		        {
		            if({listAll[inPage].content[i] as Raise}.args[j] == "")
		            {
		          		return false;
		           	}
		        }
	        }
	        else if (listAll[inPage].content[i] instanceof Set){
		        for (j in [0..{listAll[inPage].content[i] as Set}.args.size()-1])
		        {
		            if({listAll[inPage].content[i] as Set}.args[j] == "")
		            {
		          		return false;
		           	}
		        }
	        }
	        else if (listAll[inPage].content[i] instanceof Testify){
		        for (j in [0..{listAll[inPage].content[i] as Testify}.args.size()-1])
		        {
		            if({listAll[inPage].content[i] as Testify}.args[j] == "")
		            {
		          		return false;
		           	}
		        }
	        }

	        else if (listAll[inPage].content[i] instanceof While){
		        for (j in [0..{listAll[inPage].content[i] as While}.args.size()-1])
		        {
		            if({listAll[inPage].content[i] as While}.args[j] == "")
		            {
		          		return false;
		           	}
		        }
	        }
	    }
	    return yes;
	}
	
	public function areFieldsFull(inLine:Integer):Boolean
	{
	    var yes = false;
	    for (i in [0..listAll[page].content.size()])
	    {
	        if (listAll[page].content[i] instanceof Note)
	        {
	            if ({listAll[page].content[i] as Note}.line == inLine)
	            {
		            if({listAll[page].content[i] as Note}.args[0] != "" and
		               {listAll[page].content[i] as Note}.args[1] != "")
		               {
		          			yes = true;
		           	   }
		         }
	        }
	    }
	    return yes;
	}
	
	// gets the text value of Note  (the var name)
	public function getNoteName(inLine:Integer):String
	{
	    var dname = "";
	    for (i in [0..listAll[page].content.size()])
	    {
	        if (listAll[page].content[i] instanceof Note){ if ( { listAll[page].content[i] as Note}.line == inLine ){
	            dname = {listAll[page].content[i] as Note}.args[0];
	        }}
	    }
	    return dname;
	} 
	
	// gets the data type declared by Note
	public function getNoteType(inLine:Integer):String
	{
	    var dtype = "";
	    for (i in [0..listAll[page].content.size()])
	    {
	        if (listAll[page].content[i] instanceof Note){ if ( { listAll[page].content[i] as Note}.line == inLine ){
	            dtype = {listAll[page].content[i] as Note}.args[1];
	        }}
	    }
	    return dtype;
	} 
	
	// checks if it's a tile that adds user variables when used, like ROLL DICE giving allowedMoves
	public function isBonusTile(inLine:Number):Boolean
	{
	    var yes = false;
	    for (i in [0..listAll[page].content.size()])
	    {
	        if (listAll[page].content[i] instanceof RollDice){ if ( { listAll[page].content[i] as RollDice}.line == inLine ){ yes = true; break; }}
	        if (listAll[page].content[i] instanceof ListenToSuggestion){ if ( { listAll[page].content[i] as ListenToSuggestion}.line == inLine ){ yes = true; break; }}
	    }
	    return yes;
	}
	
	// get the names of the bonus user variable
	public function getBonusNames(inLine:Number):String[]
	{
	    var varnames:String[];
	    for (i in [0..listAll[page].content.size()])
	    {
	        if (listAll[page].content[i] instanceof RollDice){ if ( { listAll[page].content[i] as RollDice}.line == inLine ){
	            insert { listAll[page].content[i] as RollDice}.bonusVariables into varnames;
	            break;
	            }}
	        if (listAll[page].content[i] instanceof ListenToSuggestion){ if ( { listAll[page].content[i] as ListenToSuggestion}.line == inLine ){
	            insert { listAll[page].content[i] as ListenToSuggestion}.bonusVariables into varnames;
	            break;
	            }}
	    }
	    return varnames;
	}
	
	// get the names of the bonus user variable TYPES
	public function getBonusTypes(inLine:Number):String[]
	{
	    var vartypes:String[];
	    for (i in [0..listAll[page].content.size()])
	    {
	        if (listAll[page].content[i] instanceof RollDice){ if ( { listAll[page].content[i] as RollDice}.line == inLine ){
	            insert { listAll[page].content[i] as RollDice}.bonusVariableTypes into vartypes;
	            break;
	            }}
	        if (listAll[page].content[i] instanceof ListenToSuggestion){ if ( { listAll[page].content[i] as ListenToSuggestion}.line == inLine ){
	            insert { listAll[page].content[i] as ListenToSuggestion}.bonusVariableTypes into vartypes;
	            break;
	            }}
	    }
	    return vartypes;
	}
	
	// checks if tile is a Note
	public function isNoteTile(inLine:Integer):Boolean
	{
	    var yes = false;
	    for (i in [0..listAll[page].content.size()])
	    {
	        if (listAll[page].content[i] instanceof Note){ if ( { listAll[page].content[i] as Note}.line == inLine ){ yes = true; }}
	    }
	    return yes;
	}
	
	// checks if tile is a Set tile
	public function isSetTile(inLine:Integer):Boolean
	{
	    var yes = false;
	    for (i in [0..listAll[page].content.size()])
	    {
	        if (listAll[page].content[i] instanceof Set){ if ( { listAll[page].content[i] as Set}.line == inLine ){ yes = true; }}
	    }
	    return yes;
	}
	
	public function getSetFieldType1(inLine:Integer):Integer
	{
	    for (i in [0..listAll[page].content.size()])
	    {
	        if (listAll[page].content[i] instanceof Set)
	        {
	            if ({listAll[page].content[i] as Set}.line == inLine)
	            {
	                return {listAll[page].content[i] as Set}.dataType[0];
		        }
	        }
	    }
	    return 0;
	}
	
	// checks if tile is a condition tile
	public function isConditionTile(inLine:Integer):Boolean
	{
	    var yes = false;
	    for (i in [0..listAll[page].content.size()])
	    {
	        if (listAll[page].content[i] instanceof If){ if ( { listAll[page].content[i] as If}.line == inLine ){ yes = true; }}
	        if (listAll[page].content[i] instanceof While){ if ( { listAll[page].content[i] as While}.line == inLine ){ yes = true; }}
	    }
	    return yes;
	}
	
	public function isGoToTile(inLine:Integer):Boolean
	{
	    for (i in [0..listAll[page].content.size()])
	    {
	        if (listAll[page].content[i] instanceof GoTo){ if ( { listAll[page].content[i] as GoTo}.line == inLine ){ return true; }}
	    }
	    return false;
	}
	
	// checks if tile can have bonus vars
	public function canReadBonusVar(inLine:Integer, argClick:Integer):Boolean
	{
	    // must be a SET tile and
	    var isSetTile = false;
	    for (i in [0..listAll[page].content.size()])
	    {
	        if (listAll[page].content[i] instanceof Set){ if ( { listAll[page].content[i] as Set}.line == inLine ){ isSetTile = true; }}
	    }
	    
	    var isArg1Clicked = false;
	    // must have clicked arg1 (second arg)
	    if (argClick ==1)
	    {
	        isArg1Clicked = true;
	    }
	    
	    if(isSetTile and isArg1Clicked)
	    {
	        return true;
	    }
	    else
	    {
	        return false;
	    }
	}
	
	// checks if tile is a suggest or accuse tile
	public function isSuggestAccuseTile(inLine:Integer):Boolean
	{
	    var yes = false;
	    for (i in [0..listAll[page].content.size()])
	    {
	        if (listAll[page].content[i] instanceof Suggest){ if ( { listAll[page].content[i] as Suggest}.line == inLine ){ yes = true; }}
	        if (listAll[page].content[i] instanceof Accuse){ if ( { listAll[page].content[i] as Accuse}.line == inLine ){ yes = true; }}
	    }
	    return yes;
	}
	
	// checks if tile is for disproving
	public function isDisproveTile(inLine:Integer):Boolean
	{
	    var yes = false;
	    for (i in [0..listAll[page].content.size()])
	    {
	        if (listAll[page].content[i] instanceof DisproveSuggestionWith){ if ( { listAll[page].content[i] as DisproveSuggestionWith}.line == inLine ){ yes = true; }}
	    }
	    return yes;
	}
	
	public function getCondFieldType1(inLine:Integer):Integer
	{
	    for (i in [0..listAll[page].content.size()])
	    {
	        if (listAll[page].content[i] instanceof If)
	        {
	            if ({listAll[page].content[i] as If}.line == inLine)
	            {
	                return {listAll[page].content[i] as If}.dataType[0];
		         }
	        }
			if (listAll[page].content[i] instanceof While)
	        {
	            if ({listAll[page].content[i] as While}.line == inLine)
	            {
	                return {listAll[page].content[i] as While}.dataType[0];
		        }
	        }
	    }
	    return 0;
	}
	
	// checks if a line has a tile in it	
	public function isLineUsed():Boolean
	{
	    var used = false;
	    //for (i in [0..tileList.content.size()])
	    for (i in [0..listAll[page].content.size()])
	    {
	        if (listAll[page].content[i] instanceof RollDice){ 		if ( { listAll[page].content[i] as RollDice}.line 		== lineClick ){ used = true; }}
	        if (listAll[page].content[i] instanceof TakeShortcut){ 	if ( { listAll[page].content[i] as TakeShortcut}.line	== lineClick ){ used = true; }}
	        if (listAll[page].content[i] instanceof Suggest){ 		if ( { listAll[page].content[i] as Suggest}.line 		== lineClick ){ used = true; }}
	        if (listAll[page].content[i] instanceof Accuse){ 		if ( { listAll[page].content[i] as Accuse}.line 		== lineClick ){ used = true; }}
	        if (listAll[page].content[i] instanceof GoTo){ 			if ( { listAll[page].content[i] as GoTo}.line 			== lineClick ){ used = true; }}
	        if (listAll[page].content[i] instanceof Note){ 			if ( { listAll[page].content[i] as Note}.line 			== lineClick ){ used = true; }}
	        if (listAll[page].content[i] instanceof Increase){ 		if ( { listAll[page].content[i] as Increase}.line 		== lineClick ){ used = true; }}
	        if (listAll[page].content[i] instanceof Decrease){ 		if ( { listAll[page].content[i] as Decrease}.line 		== lineClick ){ used = true; }}
	        if (listAll[page].content[i] instanceof Multiply){ 		if ( { listAll[page].content[i] as Multiply}.line 		== lineClick ){ used = true; }}
	        if (listAll[page].content[i] instanceof Divide){ 		if ( { listAll[page].content[i] as Divide}.line 		== lineClick ){ used = true; }}
	        if (listAll[page].content[i] instanceof Raise){ 		if ( { listAll[page].content[i] as Raise}.line 			== lineClick ){ used = true; }}
	        if (listAll[page].content[i] instanceof Testify){ 		if ( { listAll[page].content[i] as Testify}.line 		== lineClick ){ used = true; }}
	        if (listAll[page].content[i] instanceof Falsify){ 		if ( { listAll[page].content[i] as Falsify}.line 		== lineClick ){ used = true; }}
	        if (listAll[page].content[i] instanceof If){ 			if ( { listAll[page].content[i] as If}.line 			== lineClick ){ used = true; }}
	        if (listAll[page].content[i] instanceof While){ 		if ( { listAll[page].content[i] as While}.line 			== lineClick ){ used = true; }}
	        if (listAll[page].content[i] instanceof Set){ 			if ( { listAll[page].content[i] as Set}.line 			== lineClick ){ used = true; }}
	        if (listAll[page].content[i] instanceof EndCondition){	if ( { listAll[page].content[i] as EndCondition}.line 	== lineClick ){ used = true; }}
	        if (listAll[page].content[i] instanceof BreakCondition){if ( { listAll[page].content[i] as BreakCondition}.line	== lineClick ){ used = true; }}
	        if (listAll[page].content[i] instanceof DisproveSuggestionWith){if ( { listAll[page].content[i] as DisproveSuggestionWith}.line	== lineClick ){ used = true; }}
	    }
	    return used;
	}
	
	public function getListOfAllowedDataTypes():Boolean[]
	{
	    var ret:Boolean[] = [];
	    for (i in [0..listAll[page].content.size()])
	    {
	        //if (listAll[page].content[i] instanceof RollDice){ 		if ( { listAll[page].content[i] as RollDice}.line 		== lineClick ){  }}
	        //if (listAll[page].content[i] instanceof TakeShortcut){ 	if ( { listAll[page].content[i] as TakeShortcut}.line	== lineClick ){ used = true; }}
	        if (listAll[page].content[i] instanceof Suggest){ 		if ( { listAll[page].content[i] as Suggest}.line 		== lineClick ){ ret = { listAll[page].content[i] as Suggest}.getAllowedDataTypes(); }}
	        if (listAll[page].content[i] instanceof Accuse){ 		if ( { listAll[page].content[i] as Accuse}.line 		== lineClick ){ ret = { listAll[page].content[i] as Accuse}.getAllowedDataTypes(); }}
	        if (listAll[page].content[i] instanceof GoTo){ 			if ( { listAll[page].content[i] as GoTo}.line 			== lineClick ){ ret = { listAll[page].content[i] as GoTo}.getAllowedDataTypes(); }}
	        if (listAll[page].content[i] instanceof Note){ 			if ( { listAll[page].content[i] as Note}.line 			== lineClick ){ ret = { listAll[page].content[i] as Note}.getAllowedDataTypes(); }}
	        if (listAll[page].content[i] instanceof Increase){ 		if ( { listAll[page].content[i] as Increase}.line 		== lineClick ){ ret = { listAll[page].content[i] as Increase}.getAllowedDataTypes(); }}
	        if (listAll[page].content[i] instanceof Decrease){ 		if ( { listAll[page].content[i] as Decrease}.line 		== lineClick ){ ret = { listAll[page].content[i] as Decrease}.getAllowedDataTypes(); }}
	        if (listAll[page].content[i] instanceof Multiply){ 		if ( { listAll[page].content[i] as Multiply}.line 		== lineClick ){ ret = { listAll[page].content[i] as Multiply}.getAllowedDataTypes(); }}
	        if (listAll[page].content[i] instanceof Divide){ 		if ( { listAll[page].content[i] as Divide}.line 		== lineClick ){ ret = { listAll[page].content[i] as Divide}.getAllowedDataTypes(); }}
	        if (listAll[page].content[i] instanceof Raise){ 		if ( { listAll[page].content[i] as Raise}.line 			== lineClick ){ ret = { listAll[page].content[i] as Raise}.getAllowedDataTypes(); }}
	        if (listAll[page].content[i] instanceof Testify){ 		if ( { listAll[page].content[i] as Testify}.line 		== lineClick ){ ret = { listAll[page].content[i] as Testify}.getAllowedDataTypes(); }}
	        if (listAll[page].content[i] instanceof Falsify){ 		if ( { listAll[page].content[i] as Falsify}.line 		== lineClick ){ ret = { listAll[page].content[i] as Falsify}.getAllowedDataTypes(); }}
	        if (listAll[page].content[i] instanceof If){ 			if ( { listAll[page].content[i] as If}.line 			== lineClick ){ ret = { listAll[page].content[i] as If}.getAllowedDataTypes(); }}
	        if (listAll[page].content[i] instanceof While){ 		if ( { listAll[page].content[i] as While}.line 			== lineClick ){ ret = { listAll[page].content[i] as While}.getAllowedDataTypes(); }}
	        if (listAll[page].content[i] instanceof Set){ 			if ( { listAll[page].content[i] as Set}.line 			== lineClick ){ ret = { listAll[page].content[i] as Set}.getAllowedDataTypes(); }}
	        if (listAll[page].content[i] instanceof EndCondition){	if ( { listAll[page].content[i] as EndCondition}.line 	== lineClick ){ ret = { listAll[page].content[i] as EndCondition}.getAllowedDataTypes(); }}
	        if (listAll[page].content[i] instanceof BreakCondition){if ( { listAll[page].content[i] as BreakCondition}.line	== lineClick ){ ret = { listAll[page].content[i] as BreakCondition}.getAllowedDataTypes(); }}
	        if (listAll[page].content[i] instanceof DisproveSuggestionWith){if ( { listAll[page].content[i] as DisproveSuggestionWith}.line	== lineClick ){ ret = { listAll[page].content[i] as DisproveSuggestionWith}.getAllowedDataTypes(); }}

	    }
	    return ret;
	}
	/*
	public function getListOfSpecialVariables_Number():String[]
	{
	    var ret:String[] = ["Error in EditorPanel", "getListOfSpecialVariables"];
	    for (i in [0..listAll[page].content.size()])
	    {
	        //if (listAll[page].content[i] instanceof RollDice){ 		if ( { listAll[page].content[i] as RollDice}.line 		== lineClick ){  }}
	        //if (listAll[page].content[i] instanceof TakeShortcut){ 	if ( { listAll[page].content[i] as TakeShortcut}.line	== lineClick ){ used = true; }}
	        //if (listAll[page].content[i] instanceof Suggest){ 		if ( { listAll[page].content[i] as Suggest}.line 		== lineClick ){ ret = { listAll[page].content[i] as Suggest}.argClick; }}
	        //if (listAll[page].content[i] instanceof Accuse){ 		if ( { listAll[page].content[i] as Accuse}.line 		== lineClick ){ used = true; }}
	        //if (listAll[page].content[i] instanceof GoTo){ 			if ( { listAll[page].content[i] as GoTo}.line 			== lineClick ){ used = true; }}
	        if (listAll[page].content[i] instanceof Note){ 			if ( { listAll[page].content[i] as Note}.line 			== lineClick ){ ret = { listAll[page].content[i] as Note}.getSpecialVariables_Number(); }}
	        if (listAll[page].content[i] instanceof Increase){ 		if ( { listAll[page].content[i] as Increase}.line 		== lineClick ){ ret = { listAll[page].content[i] as Increase}.getSpecialVariables_Number(); }}
	        if (listAll[page].content[i] instanceof Decrease){ 		if ( { listAll[page].content[i] as Decrease}.line 		== lineClick ){ ret = { listAll[page].content[i] as Decrease}.getSpecialVariables_Number(); }}
	        if (listAll[page].content[i] instanceof Multiply){ 		if ( { listAll[page].content[i] as Multiply}.line 		== lineClick ){ ret = { listAll[page].content[i] as Multiply}.getSpecialVariables_Number(); }}
	        if (listAll[page].content[i] instanceof Divide){ 		if ( { listAll[page].content[i] as Divide}.line 		== lineClick ){ ret = { listAll[page].content[i] as Divide}.getSpecialVariables_Number(); }}
	        if (listAll[page].content[i] instanceof Raise){ 		if ( { listAll[page].content[i] as Raise}.line 			== lineClick ){ ret = { listAll[page].content[i] as Raise}.getSpecialVariables_Number(); }}
	        if (listAll[page].content[i] instanceof Testify){ 		if ( { listAll[page].content[i] as Testify}.line 		== lineClick ){ ret = { listAll[page].content[i] as Testify}.getSpecialVariables_Number(); }}
	        if (listAll[page].content[i] instanceof Falsify){ 		if ( { listAll[page].content[i] as Falsify}.line 		== lineClick ){ ret = { listAll[page].content[i] as Falsify}.getSpecialVariables_Number(); }}
	        if (listAll[page].content[i] instanceof If){ 			if ( { listAll[page].content[i] as If}.line 			== lineClick ){ ret = { listAll[page].content[i] as If}.getSpecialVariables_Number(); }}
	        if (listAll[page].content[i] instanceof While){ 		if ( { listAll[page].content[i] as While}.line 			== lineClick ){ ret = { listAll[page].content[i] as While}.getSpecialVariables_Number(); }}
	        if (listAll[page].content[i] instanceof Set){ 			if ( { listAll[page].content[i] as Set}.line 			== lineClick ){ ret = { listAll[page].content[i] as Set}.getSpecialVariables_Number(); }}
	        if (listAll[page].content[i] instanceof EndCondition){ 	if ( { listAll[page].content[i] as EndCondition}.line 	== lineClick ){ ret = { listAll[page].content[i] as EndCondition}.getSpecialVariables_Number(); }}
	        if (listAll[page].content[i] instanceof BreakCondition){if ( { listAll[page].content[i] as BreakCondition}.line	== lineClick ){ ret = { listAll[page].content[i] as BreakCondition}.getSpecialVariables_Number(); }}
	        if (listAll[page].content[i] instanceof DisproveSuggestionWith){if ( { listAll[page].content[i] as DisproveSuggestionWith}.line	== lineClick ){ ret = { listAll[page].content[i] as DisproveSuggestionWith}.getSpecialVariables_Number(); }}
	    }
	    return ret;
	}
	
	public function getListOfSpecialVariables_Word():String[]
	{
	    var ret:String[] = ["Error in EditorPanel", "getListOfSpecialVariables"];
	    for (i in [0..listAll[page].content.size()])
	    {
	        //if (listAll[page].content[i] instanceof RollDice){ 		if ( { listAll[page].content[i] as RollDice}.line 		== lineClick ){  }}
	        //if (listAll[page].content[i] instanceof TakeShortcut){ 	if ( { listAll[page].content[i] as TakeShortcut}.line	== lineClick ){ used = true; }}
	        //if (listAll[page].content[i] instanceof Suggest){ 		if ( { listAll[page].content[i] as Suggest}.line 		== lineClick ){ ret = { listAll[page].content[i] as Suggest}.argClick; }}
	        //if (listAll[page].content[i] instanceof Accuse){ 		if ( { listAll[page].content[i] as Accuse}.line 		== lineClick ){ used = true; }}
	        //if (listAll[page].content[i] instanceof GoTo){ 			if ( { listAll[page].content[i] as GoTo}.line 			== lineClick ){ used = true; }}
	        if (listAll[page].content[i] instanceof Note){ 			if ( { listAll[page].content[i] as Note}.line 			== lineClick ){ ret = { listAll[page].content[i] as Note}.getSpecialVariables_Word(); }}
	        if (listAll[page].content[i] instanceof Increase){ 		if ( { listAll[page].content[i] as Increase}.line 		== lineClick ){ ret = { listAll[page].content[i] as Increase}.getSpecialVariables_Word(); }}
	        if (listAll[page].content[i] instanceof Decrease){ 		if ( { listAll[page].content[i] as Decrease}.line 		== lineClick ){ ret = { listAll[page].content[i] as Decrease}.getSpecialVariables_Word(); }}
	        if (listAll[page].content[i] instanceof Multiply){ 		if ( { listAll[page].content[i] as Multiply}.line 		== lineClick ){ ret = { listAll[page].content[i] as Multiply}.getSpecialVariables_Word(); }}
	        if (listAll[page].content[i] instanceof Divide){ 		if ( { listAll[page].content[i] as Divide}.line 		== lineClick ){ ret = { listAll[page].content[i] as Divide}.getSpecialVariables_Word(); }}
	        if (listAll[page].content[i] instanceof Raise){ 		if ( { listAll[page].content[i] as Raise}.line 			== lineClick ){ ret = { listAll[page].content[i] as Raise}.getSpecialVariables_Word(); }}
	        if (listAll[page].content[i] instanceof Testify){ 		if ( { listAll[page].content[i] as Testify}.line 		== lineClick ){ ret = { listAll[page].content[i] as Testify}.getSpecialVariables_Word(); }}
	        if (listAll[page].content[i] instanceof Falsify){ 		if ( { listAll[page].content[i] as Falsify}.line 		== lineClick ){ ret = { listAll[page].content[i] as Falsify}.getSpecialVariables_Word(); }}
	        if (listAll[page].content[i] instanceof If){ 			if ( { listAll[page].content[i] as If}.line 			== lineClick ){ ret = { listAll[page].content[i] as If}.getSpecialVariables_Word(); }}
	        if (listAll[page].content[i] instanceof While){ 		if ( { listAll[page].content[i] as While}.line 			== lineClick ){ ret = { listAll[page].content[i] as While}.getSpecialVariables_Word(); }}
	        if (listAll[page].content[i] instanceof Set){ 			if ( { listAll[page].content[i] as Set}.line 			== lineClick ){ ret = { listAll[page].content[i] as Set}.getSpecialVariables_Word(); }}
	        if (listAll[page].content[i] instanceof EndCondition){ 	if ( { listAll[page].content[i] as EndCondition}.line 	== lineClick ){ ret = { listAll[page].content[i] as EndCondition}.getSpecialVariables_Word(); }}
	        if (listAll[page].content[i] instanceof BreakCondition){if ( { listAll[page].content[i] as BreakCondition}.line	== lineClick ){ ret = { listAll[page].content[i] as BreakCondition}.getSpecialVariables_Word(); }}
	        if (listAll[page].content[i] instanceof DisproveSuggestionWith){if ( { listAll[page].content[i] as DisproveSuggestionWith}.line	== lineClick ){ ret = { listAll[page].content[i] as DisproveSuggestionWith}.getSpecialVariables_Word(); }}
	    }
	    return ret;
	}
	
	public function getListOfSpecialVariables_Truth():String[]
	{
	    var ret:String[] = ["Error in EditorPanel", "getListOfSpecialVariables"];
	    for (i in [0..listAll[page].content.size()])
	    {
	        //if (listAll[page].content[i] instanceof RollDice){ 		if ( { listAll[page].content[i] as RollDice}.line 		== lineClick ){  }}
	        //if (listAll[page].content[i] instanceof TakeShortcut){ 	if ( { listAll[page].content[i] as TakeShortcut}.line	== lineClick ){ used = true; }}
	        //if (listAll[page].content[i] instanceof Suggest){ 		if ( { listAll[page].content[i] as Suggest}.line 		== lineClick ){ ret = { listAll[page].content[i] as Suggest}.argClick; }}
	        //if (listAll[page].content[i] instanceof Accuse){ 		if ( { listAll[page].content[i] as Accuse}.line 		== lineClick ){ used = true; }}
	        //if (listAll[page].content[i] instanceof GoTo){ 			if ( { listAll[page].content[i] as GoTo}.line 			== lineClick ){ used = true; }}
	        if (listAll[page].content[i] instanceof Note){ 			if ( { listAll[page].content[i] as Note}.line 			== lineClick ){ ret = { listAll[page].content[i] as Note}.getSpecialVariables_Truth(); }}
	        if (listAll[page].content[i] instanceof Increase){ 		if ( { listAll[page].content[i] as Increase}.line 		== lineClick ){ ret = { listAll[page].content[i] as Increase}.getSpecialVariables_Truth(); }}
	        if (listAll[page].content[i] instanceof Decrease){ 		if ( { listAll[page].content[i] as Decrease}.line 		== lineClick ){ ret = { listAll[page].content[i] as Decrease}.getSpecialVariables_Truth(); }}
	        if (listAll[page].content[i] instanceof Multiply){ 		if ( { listAll[page].content[i] as Multiply}.line 		== lineClick ){ ret = { listAll[page].content[i] as Multiply}.getSpecialVariables_Truth(); }}
	        if (listAll[page].content[i] instanceof Divide){ 		if ( { listAll[page].content[i] as Divide}.line 		== lineClick ){ ret = { listAll[page].content[i] as Divide}.getSpecialVariables_Truth(); }}
	        if (listAll[page].content[i] instanceof Raise){ 		if ( { listAll[page].content[i] as Raise}.line 			== lineClick ){ ret = { listAll[page].content[i] as Raise}.getSpecialVariables_Truth(); }}
	        if (listAll[page].content[i] instanceof Testify){ 		if ( { listAll[page].content[i] as Testify}.line 		== lineClick ){ ret = { listAll[page].content[i] as Testify}.getSpecialVariables_Truth(); }}
	        if (listAll[page].content[i] instanceof Falsify){ 		if ( { listAll[page].content[i] as Falsify}.line 		== lineClick ){ ret = { listAll[page].content[i] as Falsify}.getSpecialVariables_Truth(); }}
	        if (listAll[page].content[i] instanceof If){ 			if ( { listAll[page].content[i] as If}.line 			== lineClick ){ ret = { listAll[page].content[i] as If}.getSpecialVariables_Truth(); }}
	        if (listAll[page].content[i] instanceof While){ 		if ( { listAll[page].content[i] as While}.line 			== lineClick ){ ret = { listAll[page].content[i] as While}.getSpecialVariables_Truth(); }}
	        if (listAll[page].content[i] instanceof Set){ 			if ( { listAll[page].content[i] as Set}.line 			== lineClick ){ ret = { listAll[page].content[i] as Set}.getSpecialVariables_Truth(); }}
	        if (listAll[page].content[i] instanceof EndCondition){ 	if ( { listAll[page].content[i] as EndCondition}.line 	== lineClick ){ ret = { listAll[page].content[i] as EndCondition}.getSpecialVariables_Truth(); }}
	        if (listAll[page].content[i] instanceof BreakCondition){if ( { listAll[page].content[i] as BreakCondition}.line	== lineClick ){ ret = { listAll[page].content[i] as BreakCondition}.getSpecialVariables_Truth(); }}
	        if (listAll[page].content[i] instanceof DisproveSuggestionWith){if ( { listAll[page].content[i] as DisproveSuggestionWith}.line	== lineClick ){ ret = { listAll[page].content[i] as DisproveSuggestionWith}.getSpecialVariables_Truth(); }}
	    }
	    return ret;
	}
	
	public function getListOfSpecialVariables_Special():String[]
	{
	    var ret:String[] = ["Error in EditorPanel", "getListOfSpecialVariables"];
	    for (i in [0..listAll[page].content.size()])
	    {
	        //if (listAll[page].content[i] instanceof RollDice){ 		if ( { listAll[page].content[i] as RollDice}.line 		== lineClick ){  }}
	        //if (listAll[page].content[i] instanceof TakeShortcut){ 	if ( { listAll[page].content[i] as TakeShortcut}.line	== lineClick ){ used = true; }}
	        //if (listAll[page].content[i] instanceof Suggest){ 		if ( { listAll[page].content[i] as Suggest}.line 		== lineClick ){ ret = { listAll[page].content[i] as Suggest}.argClick; }}
	        //if (listAll[page].content[i] instanceof Accuse){ 		if ( { listAll[page].content[i] as Accuse}.line 		== lineClick ){ used = true; }}
	        //if (listAll[page].content[i] instanceof GoTo){ 			if ( { listAll[page].content[i] as GoTo}.line 			== lineClick ){ used = true; }}
	        if (listAll[page].content[i] instanceof Note){ 			if ( { listAll[page].content[i] as Note}.line 			== lineClick ){ ret = { listAll[page].content[i] as Note}.getSpecialVariables_Special(); }}
	        if (listAll[page].content[i] instanceof Increase){ 		if ( { listAll[page].content[i] as Increase}.line 		== lineClick ){ ret = { listAll[page].content[i] as Increase}.getSpecialVariables_Special(); }}
	        if (listAll[page].content[i] instanceof Decrease){ 		if ( { listAll[page].content[i] as Decrease}.line 		== lineClick ){ ret = { listAll[page].content[i] as Decrease}.getSpecialVariables_Special(); }}
	        if (listAll[page].content[i] instanceof Multiply){ 		if ( { listAll[page].content[i] as Multiply}.line 		== lineClick ){ ret = { listAll[page].content[i] as Multiply}.getSpecialVariables_Special(); }}
	        if (listAll[page].content[i] instanceof Divide){ 		if ( { listAll[page].content[i] as Divide}.line 		== lineClick ){ ret = { listAll[page].content[i] as Divide}.getSpecialVariables_Special(); }}
	        if (listAll[page].content[i] instanceof Raise){ 		if ( { listAll[page].content[i] as Raise}.line 			== lineClick ){ ret = { listAll[page].content[i] as Raise}.getSpecialVariables_Special(); }}
	        if (listAll[page].content[i] instanceof Testify){ 		if ( { listAll[page].content[i] as Testify}.line 		== lineClick ){ ret = { listAll[page].content[i] as Testify}.getSpecialVariables_Special(); }}
	        if (listAll[page].content[i] instanceof Falsify){ 		if ( { listAll[page].content[i] as Falsify}.line 		== lineClick ){ ret = { listAll[page].content[i] as Falsify}.getSpecialVariables_Special(); }}
	        if (listAll[page].content[i] instanceof If){ 			if ( { listAll[page].content[i] as If}.line 			== lineClick ){ ret = { listAll[page].content[i] as If}.getSpecialVariables_Special(); }}
	        if (listAll[page].content[i] instanceof While){ 		if ( { listAll[page].content[i] as While}.line 			== lineClick ){ ret = { listAll[page].content[i] as While}.getSpecialVariables_Special(); }}
	        if (listAll[page].content[i] instanceof Set){ 			if ( { listAll[page].content[i] as Set}.line 			== lineClick ){ ret = { listAll[page].content[i] as Set}.getSpecialVariables_Special(); }}
	        if (listAll[page].content[i] instanceof EndCondition){ 	if ( { listAll[page].content[i] as EndCondition}.line 	== lineClick ){ ret = { listAll[page].content[i] as EndCondition}.getSpecialVariables_Special(); }}
	        if (listAll[page].content[i] instanceof BreakCondition){if ( { listAll[page].content[i] as BreakCondition}.line	== lineClick ){ ret = { listAll[page].content[i] as BreakCondition}.getSpecialVariables_Special(); }}
	        if (listAll[page].content[i] instanceof DisproveSuggestionWith){if ( { listAll[page].content[i] as DisproveSuggestionWith}.line	== lineClick ){ ret = { listAll[page].content[i] as DisproveSuggestionWith}.getSpecialVariables_Special(); }}
	    }
	    return ret;
	}
	*/

	public function getListOfSpecialVariables():String[]
	{
	    var ret:String[] = ["Error in EditorPanel", "getListOfSpecialVariables"];
	    for (i in [0..listAll[page].content.size()])
	    {
	        //if (listAll[page].content[i] instanceof RollDice){ 		if ( { listAll[page].content[i] as RollDice}.line 		== lineClick ){  }}
	        //if (listAll[page].content[i] instanceof TakeShortcut){ 	if ( { listAll[page].content[i] as TakeShortcut}.line	== lineClick ){ used = true; }}
	        if (listAll[page].content[i] instanceof Suggest){ 		if ( { listAll[page].content[i] as Suggest}.line 		== lineClick ){ ret = { listAll[page].content[i] as Suggest}.getSpecialVariables(); }}
	        if (listAll[page].content[i] instanceof Accuse){ 		if ( { listAll[page].content[i] as Accuse}.line 		== lineClick ){ ret = { listAll[page].content[i] as Accuse}.getSpecialVariables(); }}
	        if (listAll[page].content[i] instanceof GoTo){ 			if ( { listAll[page].content[i] as GoTo}.line 			== lineClick ){ ret = { listAll[page].content[i] as GoTo}.getSpecialVariables(); }}
	        if (listAll[page].content[i] instanceof Note){ 			if ( { listAll[page].content[i] as Note}.line 			== lineClick ){ ret = { listAll[page].content[i] as Note}.getSpecialVariables(); }}
	        if (listAll[page].content[i] instanceof Increase){ 		if ( { listAll[page].content[i] as Increase}.line 		== lineClick ){ ret = { listAll[page].content[i] as Increase}.getSpecialVariables(); }}
	        if (listAll[page].content[i] instanceof Decrease){ 		if ( { listAll[page].content[i] as Decrease}.line 		== lineClick ){ ret = { listAll[page].content[i] as Decrease}.getSpecialVariables(); }}
	        if (listAll[page].content[i] instanceof Multiply){ 		if ( { listAll[page].content[i] as Multiply}.line 		== lineClick ){ ret = { listAll[page].content[i] as Multiply}.getSpecialVariables(); }}
	        if (listAll[page].content[i] instanceof Divide){ 		if ( { listAll[page].content[i] as Divide}.line 		== lineClick ){ ret = { listAll[page].content[i] as Divide}.getSpecialVariables(); }}
	        if (listAll[page].content[i] instanceof Raise){ 		if ( { listAll[page].content[i] as Raise}.line 			== lineClick ){ ret = { listAll[page].content[i] as Raise}.getSpecialVariables(); }}
	        if (listAll[page].content[i] instanceof Testify){ 		if ( { listAll[page].content[i] as Testify}.line 		== lineClick ){ ret = { listAll[page].content[i] as Testify}.getSpecialVariables(); }}
	        if (listAll[page].content[i] instanceof Falsify){ 		if ( { listAll[page].content[i] as Falsify}.line 		== lineClick ){ ret = { listAll[page].content[i] as Falsify}.getSpecialVariables(); }}
	        if (listAll[page].content[i] instanceof If){ 			if ( { listAll[page].content[i] as If}.line 			== lineClick ){ ret = { listAll[page].content[i] as If}.getSpecialVariables(); }}
	        if (listAll[page].content[i] instanceof While){ 		if ( { listAll[page].content[i] as While}.line 			== lineClick ){ ret = { listAll[page].content[i] as While}.getSpecialVariables(); }}
	        if (listAll[page].content[i] instanceof Set){ 			if ( { listAll[page].content[i] as Set}.line 			== lineClick ){ ret = { listAll[page].content[i] as Set}.getSpecialVariables(); }}
	        if (listAll[page].content[i] instanceof EndCondition){ 	if ( { listAll[page].content[i] as EndCondition}.line 	== lineClick ){ ret = { listAll[page].content[i] as EndCondition}.getSpecialVariables(); }}
	        if (listAll[page].content[i] instanceof BreakCondition){if ( { listAll[page].content[i] as BreakCondition}.line	== lineClick ){ ret = { listAll[page].content[i] as BreakCondition}.getSpecialVariables(); }}
	        if (listAll[page].content[i] instanceof DisproveSuggestionWith){if ( { listAll[page].content[i] as DisproveSuggestionWith}.line	== lineClick ){ ret = { listAll[page].content[i] as DisproveSuggestionWith}.getSpecialVariables(); }}
	    }
	    return ret;
	}

	public function getArgDataValue(arg:Number):Number
	{
	    var ret:Number = 0;
	    for (i in [0..listAll[page].content.size()])
	    {
	        //if (listAll[page].content[i] instanceof RollDice){ 		if ( { listAll[page].content[i] as RollDice}.line 		== lineClick ){  }}
	        //if (listAll[page].content[i] instanceof TakeShortcut){ 	if ( { listAll[page].content[i] as TakeShortcut}.line	== lineClick ){ used = true; }}
	        if (listAll[page].content[i] instanceof Suggest){ 		if ( { listAll[page].content[i] as Suggest}.line 		== lineClick ){ ret = { listAll[page].content[i] as Suggest}.getDataValue(arg as Number); }}
	        if (listAll[page].content[i] instanceof Accuse){ 		if ( { listAll[page].content[i] as Accuse}.line 		== lineClick ){ ret = { listAll[page].content[i] as Accuse}.getDataValue(arg as Number); }}
	        if (listAll[page].content[i] instanceof GoTo){ 			if ( { listAll[page].content[i] as GoTo}.line 			== lineClick ){ ret = { listAll[page].content[i] as GoTo}.getDataValue(arg as Number); }}
	        if (listAll[page].content[i] instanceof Note){ 			if ( { listAll[page].content[i] as Note}.line 			== lineClick ){ ret = { listAll[page].content[i] as Note}.getDataValue(arg as Number); }}
	        if (listAll[page].content[i] instanceof Increase){ 		if ( { listAll[page].content[i] as Increase}.line 		== lineClick ){ ret = { listAll[page].content[i] as Increase}.getDataValue(arg as Number); }}
	        if (listAll[page].content[i] instanceof Decrease){ 		if ( { listAll[page].content[i] as Decrease}.line 		== lineClick ){ ret = { listAll[page].content[i] as Decrease}.getDataValue(arg as Number); }}
	        if (listAll[page].content[i] instanceof Multiply){ 		if ( { listAll[page].content[i] as Multiply}.line 		== lineClick ){ ret = { listAll[page].content[i] as Multiply}.getDataValue(arg as Number); }}
	        if (listAll[page].content[i] instanceof Divide){ 		if ( { listAll[page].content[i] as Divide}.line 		== lineClick ){ ret = { listAll[page].content[i] as Divide}.getDataValue(arg as Number); }}
	        if (listAll[page].content[i] instanceof Raise){ 		if ( { listAll[page].content[i] as Raise}.line 			== lineClick ){ ret = { listAll[page].content[i] as Raise}.getDataValue(arg as Number); }}
	        if (listAll[page].content[i] instanceof Testify){ 		if ( { listAll[page].content[i] as Testify}.line 		== lineClick ){ ret = { listAll[page].content[i] as Testify}.getDataValue(arg as Number); }}
	        if (listAll[page].content[i] instanceof Falsify){ 		if ( { listAll[page].content[i] as Falsify}.line 		== lineClick ){ ret = { listAll[page].content[i] as Falsify}.getDataValue(arg as Number); }}
	        if (listAll[page].content[i] instanceof If){ 			if ( { listAll[page].content[i] as If}.line 			== lineClick ){ ret = { listAll[page].content[i] as If}.getDataValue(arg as Number); }}
	        if (listAll[page].content[i] instanceof While){ 		if ( { listAll[page].content[i] as While}.line 			== lineClick ){ ret = { listAll[page].content[i] as While}.getDataValue(arg as Number); }}
	        if (listAll[page].content[i] instanceof Set){ 			if ( { listAll[page].content[i] as Set}.line 			== lineClick ){ ret = { listAll[page].content[i] as Set}.getDataValue(arg as Number); }}
	        if (listAll[page].content[i] instanceof EndCondition){ 	if ( { listAll[page].content[i] as EndCondition}.line 	== lineClick ){ ret = { listAll[page].content[i] as EndCondition}.getDataValue(arg as Number); }}
	        if (listAll[page].content[i] instanceof BreakCondition){if ( { listAll[page].content[i] as BreakCondition}.line	== lineClick ){ ret = { listAll[page].content[i] as BreakCondition}.getDataValue(arg as Number); }}
	        if (listAll[page].content[i] instanceof DisproveSuggestionWith){if ( { listAll[page].content[i] as DisproveSuggestionWith}.line	== lineClick ){ ret = { listAll[page].content[i] as DisproveSuggestionWith}.getDataValue(arg as Number); }}
	    }
	    return ret;
	}

	public function getArgDataType(arg:Number):Number
	{
	    var ret:Number = 0;
	    for (i in [0..listAll[page].content.size()])
	    {
	        //if (listAll[page].content[i] instanceof RollDice){ 		if ( { listAll[page].content[i] as RollDice}.line 		== lineClick ){  }}
	        //if (listAll[page].content[i] instanceof TakeShortcut){ 	if ( { listAll[page].content[i] as TakeShortcut}.line	== lineClick ){ used = true; }}
	        if (listAll[page].content[i] instanceof Suggest){ 		if ( { listAll[page].content[i] as Suggest}.line 		== lineClick ){ ret = { listAll[page].content[i] as Suggest}.getDataType(arg); }}
	        if (listAll[page].content[i] instanceof Accuse){ 		if ( { listAll[page].content[i] as Accuse}.line 		== lineClick ){ ret = { listAll[page].content[i] as Accuse}.getDataType(arg); }}
	        if (listAll[page].content[i] instanceof GoTo){ 			if ( { listAll[page].content[i] as GoTo}.line 			== lineClick ){ ret = { listAll[page].content[i] as GoTo}.getDataType(arg); }}
	        if (listAll[page].content[i] instanceof Note){ 			if ( { listAll[page].content[i] as Note}.line 			== lineClick ){ ret = { listAll[page].content[i] as Note}.getDataType(arg); }}
	        if (listAll[page].content[i] instanceof Increase){ 		if ( { listAll[page].content[i] as Increase}.line 		== lineClick ){ ret = { listAll[page].content[i] as Increase}.getDataType(arg); }}
	        if (listAll[page].content[i] instanceof Decrease){ 		if ( { listAll[page].content[i] as Decrease}.line 		== lineClick ){ ret = { listAll[page].content[i] as Decrease}.getDataType(arg); }}
	        if (listAll[page].content[i] instanceof Multiply){ 		if ( { listAll[page].content[i] as Multiply}.line 		== lineClick ){ ret = { listAll[page].content[i] as Multiply}.getDataType(arg); }}
	        if (listAll[page].content[i] instanceof Divide){ 		if ( { listAll[page].content[i] as Divide}.line 		== lineClick ){ ret = { listAll[page].content[i] as Divide}.getDataType(arg); }}
	        if (listAll[page].content[i] instanceof Raise){ 		if ( { listAll[page].content[i] as Raise}.line 			== lineClick ){ ret = { listAll[page].content[i] as Raise}.getDataType(arg); }}
	        if (listAll[page].content[i] instanceof Testify){ 		if ( { listAll[page].content[i] as Testify}.line 		== lineClick ){ ret = { listAll[page].content[i] as Testify}.getDataType(arg); }}
	        if (listAll[page].content[i] instanceof Falsify){ 		if ( { listAll[page].content[i] as Falsify}.line 		== lineClick ){ ret = { listAll[page].content[i] as Falsify}.getDataType(arg); }}
	        if (listAll[page].content[i] instanceof If){ 			if ( { listAll[page].content[i] as If}.line 			== lineClick ){ ret = { listAll[page].content[i] as If}.getDataType(arg); }}
	        if (listAll[page].content[i] instanceof While){ 		if ( { listAll[page].content[i] as While}.line 			== lineClick ){ ret = { listAll[page].content[i] as While}.getDataType(arg); }}
	        if (listAll[page].content[i] instanceof Set){ 			if ( { listAll[page].content[i] as Set}.line 			== lineClick ){ ret = { listAll[page].content[i] as Set}.getDataType(arg); }}
	        if (listAll[page].content[i] instanceof EndCondition){ 	if ( { listAll[page].content[i] as EndCondition}.line 	== lineClick ){ ret = { listAll[page].content[i] as EndCondition}.getDataType(arg); }}
	        if (listAll[page].content[i] instanceof BreakCondition){if ( { listAll[page].content[i] as BreakCondition}.line == lineClick ){ ret = { listAll[page].content[i] as BreakCondition}.getDataType(arg); }}
	        if (listAll[page].content[i] instanceof DisproveSuggestionWith){if ( { listAll[page].content[i] as DisproveSuggestionWith}.line == lineClick ){ ret = { listAll[page].content[i] as DisproveSuggestionWith}.getDataType(arg); }}
	    }
	    return ret;
	}
	
	public function getListOfAllowedDataValue():Boolean[]
	{
	    var ret:Boolean[] = [];
	    for (i in [0..listAll[page].content.size()])
	    {
	        //if (listAll[page].content[i] instanceof RollDice){ 		if ( { listAll[page].content[i] as RollDice}.line 		== lineClick ){  }}
	        //if (listAll[page].content[i] instanceof TakeShortcut){ 	if ( { listAll[page].content[i] as TakeShortcut}.line	== lineClick ){ used = true; }}
	        if (listAll[page].content[i] instanceof Suggest){ 		if ( { listAll[page].content[i] as Suggest}.line 		== lineClick ){ ret = { listAll[page].content[i] as Suggest}.getAllowedDataValues(); }}
	        if (listAll[page].content[i] instanceof Accuse){ 		if ( { listAll[page].content[i] as Accuse}.line 		== lineClick ){ ret = { listAll[page].content[i] as Accuse}.getAllowedDataValues(); }}
	        if (listAll[page].content[i] instanceof GoTo){ 			if ( { listAll[page].content[i] as GoTo}.line 			== lineClick ){ ret = { listAll[page].content[i] as GoTo}.getAllowedDataValues(); }}
	        if (listAll[page].content[i] instanceof Note){ 			if ( { listAll[page].content[i] as Note}.line 			== lineClick ){ ret = { listAll[page].content[i] as Note}.getAllowedDataValues(); }}
	        if (listAll[page].content[i] instanceof Increase){ 		if ( { listAll[page].content[i] as Increase}.line 		== lineClick ){ ret = { listAll[page].content[i] as Increase}.getAllowedDataValues(); }}
	        if (listAll[page].content[i] instanceof Decrease){ 		if ( { listAll[page].content[i] as Decrease}.line 		== lineClick ){ ret = { listAll[page].content[i] as Decrease}.getAllowedDataValues(); }}
	        if (listAll[page].content[i] instanceof Multiply){ 		if ( { listAll[page].content[i] as Multiply}.line 		== lineClick ){ ret = { listAll[page].content[i] as Multiply}.getAllowedDataValues(); }}
	        if (listAll[page].content[i] instanceof Divide){ 		if ( { listAll[page].content[i] as Divide}.line 		== lineClick ){ ret = { listAll[page].content[i] as Divide}.getAllowedDataValues(); }}
	        if (listAll[page].content[i] instanceof Raise){ 		if ( { listAll[page].content[i] as Raise}.line 			== lineClick ){ ret = { listAll[page].content[i] as Raise}.getAllowedDataValues(); }}
	        if (listAll[page].content[i] instanceof Testify){ 		if ( { listAll[page].content[i] as Testify}.line 		== lineClick ){ ret = { listAll[page].content[i] as Testify}.getAllowedDataValues(); }}
	        if (listAll[page].content[i] instanceof Falsify){ 		if ( { listAll[page].content[i] as Falsify}.line 		== lineClick ){ ret = { listAll[page].content[i] as Falsify}.getAllowedDataValues(); }}
	        if (listAll[page].content[i] instanceof If){ 			if ( { listAll[page].content[i] as If}.line 			== lineClick ){ ret = { listAll[page].content[i] as If}.getAllowedDataValues(); }}
	        if (listAll[page].content[i] instanceof While){ 		if ( { listAll[page].content[i] as While}.line 			== lineClick ){ ret = { listAll[page].content[i] as While}.getAllowedDataValues(); }}
	        if (listAll[page].content[i] instanceof Set){ 			if ( { listAll[page].content[i] as Set}.line 			== lineClick ){ ret = { listAll[page].content[i] as Set}.getAllowedDataValues(); }}
	        if (listAll[page].content[i] instanceof EndCondition){ 	if ( { listAll[page].content[i] as EndCondition}.line 	== lineClick ){ ret = { listAll[page].content[i] as EndCondition}.getAllowedDataValues(); }}
	        if (listAll[page].content[i] instanceof BreakCondition){if ( { listAll[page].content[i] as BreakCondition}.line == lineClick ){ ret = { listAll[page].content[i] as BreakCondition}.getAllowedDataValues(); }}
	        if (listAll[page].content[i] instanceof DisproveSuggestionWith){if ( { listAll[page].content[i] as DisproveSuggestionWith}.line == lineClick ){ ret = { listAll[page].content[i] as DisproveSuggestionWith}.getAllowedDataValues(); }}
	    }
	    return ret;
	}
	
	public function pickTile():CustomNode
	{
	    for (i:Integer in [0..{listAll[page].content.size() as Integer}])
	    {
	        if (listAll[page].content[i] instanceof RollDice){ if ( {listAll[page].content[i] as RollDice}.line 		== lineClick )
	        {
		        var ret = {listAll[page].content[i] as RollDice};
				ret.line = 0;
	    		delete listAll[page].content[i];
	    		return ret;
		    }}

	        if (listAll[page].content[i] instanceof TakeShortcut){ if ( { listAll[page].content[i] as TakeShortcut}.line	== lineClick )
	        {
		        var ret = {listAll[page].content[i] as TakeShortcut};
				ret.line = 0;
	    		delete listAll[page].content[i];
	    		return ret;
	        }}
	        if (listAll[page].content[i] instanceof Suggest){ 		if ( { listAll[page].content[i] as Suggest}.line 		== lineClick )
	        {
		        var ret = {listAll[page].content[i] as Suggest};
				ret.line = 0;
	    		delete listAll[page].content[i];
	    		return ret;
	        }}
	        if (listAll[page].content[i] instanceof Accuse){ 		if ( { listAll[page].content[i] as Accuse}.line 			== lineClick )
	        {
		        var ret = {listAll[page].content[i] as Accuse};
				ret.line = 0;
	    		delete listAll[page].content[i];
	    		return ret;
	        }}
	        if (listAll[page].content[i] instanceof GoTo){ 			if ( { listAll[page].content[i] as GoTo}.line 			== lineClick )
	        {
		        var ret = {listAll[page].content[i] as GoTo};
				ret.line = 0;
	    		delete listAll[page].content[i];
	    		return ret;
	        }}
	        if (listAll[page].content[i] instanceof Note){ 			if ( { listAll[page].content[i] as Note}.line 			== lineClick )
	        {
		        var ret = {listAll[page].content[i] as Note};
				ret.line = 0;
	    		delete listAll[page].content[i];
	    		return ret;
	        }}
	        if (listAll[page].content[i] instanceof Increase){ 		if ( { listAll[page].content[i] as Increase}.line 		== lineClick )
	        {
		        var ret = {listAll[page].content[i] as Increase};
				ret.line = 0;
	    		delete listAll[page].content[i];
	    		return ret;
	        }}
	        if (listAll[page].content[i] instanceof Decrease){ 		if ({listAll[page].content[i] as Decrease}.line == lineClick)
	        {
		        var ret = {listAll[page].content[i] as Decrease};
				ret.line = 0;
	    		delete listAll[page].content[i];
	    		return ret;
	        }}
	        if (listAll[page].content[i] instanceof Multiply){ 		if ( { listAll[page].content[i] as Multiply}.line 		== lineClick )
	        {
		        var ret = {listAll[page].content[i] as Multiply};
				ret.line = 0;
	    		delete listAll[page].content[i];
	    		return ret;
	        }}
	        if (listAll[page].content[i] instanceof Divide){ 		if ( { listAll[page].content[i] as Divide}.line 			== lineClick )
	        {
		        var ret = {listAll[page].content[i] as Divide};
				ret.line = 0;
	    		delete listAll[page].content[i];
	    		return ret;
	        }}
	        if (listAll[page].content[i] instanceof Raise){ 			if ( { listAll[page].content[i] as Raise}.line 			== lineClick )
	        {
		        var ret = {listAll[page].content[i] as Raise};
				ret.line = 0;
	    		delete listAll[page].content[i];
	    		return ret;
	        }}
	        if (listAll[page].content[i] instanceof Testify){ 		if ( { listAll[page].content[i] as Testify}.line 		== lineClick )
	        {
		        var ret = {listAll[page].content[i] as Testify};
				ret.line = 0;
	    		delete listAll[page].content[i];
	    		return ret;
	        }}
	        if (listAll[page].content[i] instanceof Falsify){ 		if ( { listAll[page].content[i] as Falsify}.line 		== lineClick )
	        {
		        var ret = {listAll[page].content[i] as Falsify};
				ret.line = 0;
	    		delete listAll[page].content[i];
	    		return ret;
	        }}
	        if (listAll[page].content[i] instanceof If){ 			if ( { listAll[page].content[i] as If}.line 				== lineClick )
	        {
		        var ret = {listAll[page].content[i] as If};
				ret.line = 0;
	    		delete listAll[page].content[i];
	    		return ret;
	        }}
	        if (listAll[page].content[i] instanceof While){ 			if ( { listAll[page].content[i] as While}.line 			== lineClick )
	        {
		        var ret = {listAll[page].content[i] as While};
				ret.line = 0;
	    		delete listAll[page].content[i];
	    		return ret;
	        }}
	        if (listAll[page].content[i] instanceof Set){ 			if ( { listAll[page].content[i] as Set}.line 			== lineClick )
	        {
		        var ret = {listAll[page].content[i] as Set};
				ret.line = 0;
	    		delete listAll[page].content[i];
	    		return ret;
	        }}
	        if (listAll[page].content[i] instanceof EndCondition){ 			if ( { listAll[page].content[i] as EndCondition}.line 			== lineClick )
	        {
		        var ret = {listAll[page].content[i] as EndCondition};
				ret.line = 0;
	    		delete listAll[page].content[i];
	    		return ret;
	        }}
	        if (listAll[page].content[i] instanceof BreakCondition){ 			if ( { listAll[page].content[i] as BreakCondition}.line 			== lineClick )
	        {
		        var ret = {listAll[page].content[i] as BreakCondition};
				ret.line = 0;
	    		delete listAll[page].content[i];
	    		return ret;
	        }}
			if (listAll[page].content[i] instanceof ListenToSuggestion){ 			if ( { listAll[page].content[i] as ListenToSuggestion}.line 			== lineClick )
	        {
		        var ret = {listAll[page].content[i] as ListenToSuggestion};
				ret.line = 0;
	    		delete listAll[page].content[i];
	    		return ret;
	        }}
	        if (listAll[page].content[i] instanceof DisproveSuggestionWith){ 			if ( { listAll[page].content[i] as DisproveSuggestionWith}.line 			== lineClick )
	        {
		        var ret = {listAll[page].content[i] as DisproveSuggestionWith};
				ret.line = 0;
	    		delete listAll[page].content[i];
	    		return ret;
	        }}
	    }
	    
		return null;
	}


	public function addTile(tile:Node)
	{
	    //if (isDragging == false)
	    //{
		    var overwrite 		= false; 
		    var index 			= -1;
		    
		    // assign the line number of the tile.
			if (tile instanceof RollDice){  		{tile as RollDice}.line = lineClick; }
		    else if (tile instanceof TakeShortcut){	{tile as TakeShortcut}.line = lineClick; }
		    else if (tile instanceof Suggest){		{tile as Suggest}.line = lineClick; }
		    else if (tile instanceof Accuse){		{tile as Accuse}.line = lineClick; }
		    else if (tile instanceof GoTo){			{tile as GoTo}.line = lineClick; }
		    else if (tile instanceof Note){			{tile as Note}.line = lineClick; }
		    else if (tile instanceof Increase){		{tile as Increase}.line = lineClick; }
		    else if (tile instanceof Decrease){		{tile as Decrease}.line = lineClick; }
		    else if (tile instanceof Multiply){		{tile as Multiply}.line = lineClick; }
		    else if (tile instanceof Divide){		{tile as Divide}.line = lineClick; }
		    else if (tile instanceof Raise){		{tile as Raise}.line = lineClick; }
		    else if (tile instanceof Testify){		{tile as Testify}.line = lineClick; }
		    else if (tile instanceof Falsify){		{tile as Falsify}.line = lineClick; }
		    else if (tile instanceof If){			{tile as If}.line = lineClick; }
		    else if (tile instanceof While){		{tile as While}.line = lineClick; }
		    else if (tile instanceof Set){			{tile as Set}.line = lineClick; }
	   	    else if (tile instanceof EndCondition){	{tile as EndCondition}.line = lineClick; }
		    else if (tile instanceof BreakCondition){{tile as BreakCondition}.line = lineClick; }
		    else if (tile instanceof ListenToSuggestion){{tile as ListenToSuggestion}.line = lineClick; }
		    else if (tile instanceof DisproveSuggestionWith){{tile as DisproveSuggestionWith}.line = lineClick; }
		    
		    // check if we're overwriting a tile.
		    // loop through list of tiles, check if the line number of the line we clicked is already used
		    
		    for (i in [0..{listAll[page] as Group}.content.size()])
		    {
		        if ({listAll[page] as Group}.content[i] instanceof RollDice){ 		if ( { {listAll[page] as Group}.content[i] as RollDice}.line 		== lineClick ){ overwrite = true; index = i; }}
		        if ({listAll[page] as Group}.content[i] instanceof TakeShortcut){ 	if ( { {listAll[page] as Group}.content[i] as TakeShortcut}.line	== lineClick ){ overwrite = true; index = i; }}
		        if ({listAll[page] as Group}.content[i] instanceof Suggest){ 		if ( { {listAll[page] as Group}.content[i] as Suggest}.line 		== lineClick ){ overwrite = true; index = i; }}
		        if ({listAll[page] as Group}.content[i] instanceof Accuse){ 		if ( { {listAll[page] as Group}.content[i] as Accuse}.line 		== lineClick ){ overwrite = true; index = i; }}
		        if ({listAll[page] as Group}.content[i] instanceof GoTo){ 			if ( { {listAll[page] as Group}.content[i] as GoTo}.line 			== lineClick ){ overwrite = true; index = i; }}
		        if ({listAll[page] as Group}.content[i] instanceof Note){ 			if ( { {listAll[page] as Group}.content[i] as Note}.line 			== lineClick ){ overwrite = true; index = i; }}
		        if ({listAll[page] as Group}.content[i] instanceof Increase){ 		if ( { {listAll[page] as Group}.content[i] as Increase}.line 		== lineClick ){ overwrite = true; index = i; }}
		        if ({listAll[page] as Group}.content[i] instanceof Decrease){ 		if ( { {listAll[page] as Group}.content[i] as Decrease}.line 		== lineClick ){ overwrite = true; index = i; }}
		        if ({listAll[page] as Group}.content[i] instanceof Multiply){ 		if ( { {listAll[page] as Group}.content[i] as Multiply}.line 		== lineClick ){ overwrite = true; index = i; }}
		        if ({listAll[page] as Group}.content[i] instanceof Divide){ 		if ( { {listAll[page] as Group}.content[i] as Divide}.line 		== lineClick ){ overwrite = true; index = i; }}
		        if ({listAll[page] as Group}.content[i] instanceof Raise){ 		if ( { {listAll[page] as Group}.content[i] as Raise}.line 			== lineClick ){ overwrite = true; index = i; }}
		        if ({listAll[page] as Group}.content[i] instanceof Testify){ 		if ( { {listAll[page] as Group}.content[i] as Testify}.line 		== lineClick ){ overwrite = true; index = i; }}
		        if ({listAll[page] as Group}.content[i] instanceof Falsify){ 		if ( { {listAll[page] as Group}.content[i] as Falsify}.line 		== lineClick ){ overwrite = true; index = i; }}
		        if ({listAll[page] as Group}.content[i] instanceof If){ 			if ( { {listAll[page] as Group}.content[i] as If}.line 			== lineClick ){ overwrite = true; index = i; }}
		        if ({listAll[page] as Group}.content[i] instanceof While){ 		if ( { {listAll[page] as Group}.content[i] as While}.line 			== lineClick ){ overwrite = true; index = i; }}
		        if ({listAll[page] as Group}.content[i] instanceof Set){ 			if ( { {listAll[page] as Group}.content[i] as Set}.line 			== lineClick ){ overwrite = true; index = i; }}
		        if ({listAll[page] as Group}.content[i] instanceof EndCondition){ 	if ( { {listAll[page] as Group}.content[i] as EndCondition}.line 			== lineClick ){ overwrite = true; index = i; }}
		        if ({listAll[page] as Group}.content[i] instanceof BreakCondition){	if ( { {listAll[page] as Group}.content[i] as BreakCondition}.line 			== lineClick ){ overwrite = true; index = i; }}
		        if ({listAll[page] as Group}.content[i] instanceof ListenToSuggestion){	if ( { {listAll[page] as Group}.content[i] as ListenToSuggestion}.line 			== lineClick ){ overwrite = true; index = i; }}
		        if ({listAll[page] as Group}.content[i] instanceof DisproveSuggestionWith){	if ( { {listAll[page] as Group}.content[i] as DisproveSuggestionWith}.line 			== lineClick ){ overwrite = true; index = i; }}
		    }
		    
		    insert tile into {listAll[page] as Group}.content;	    
		    //println("inserted!  size: {listAll[page].content.size()} page: {page}");
		    
		    lineClick = -1;

	    //}
	}
	
	public function clearLine()
	{
	    var index = -1;

	    for (i in [0..{listAll[page].content.size() as Integer}])
	    {
	        if (listAll[page].content[i] instanceof RollDice){ 		if ( { listAll[page].content[i] as RollDice}.line 		== lineClick ){ index = i; }}
	        if (listAll[page].content[i] instanceof TakeShortcut){ 	if ( { listAll[page].content[i] as TakeShortcut}.line	== lineClick ){ index = i; }}
	        if (listAll[page].content[i] instanceof Suggest){ 		if ( { listAll[page].content[i] as Suggest}.line 		== lineClick ){ index = i; }}
	        if (listAll[page].content[i] instanceof Accuse){ 		if ( { listAll[page].content[i] as Accuse}.line 			== lineClick ){ index = i; }}
	        if (listAll[page].content[i] instanceof GoTo){ 			if ( { listAll[page].content[i] as GoTo}.line 			== lineClick ){ index = i; }}
	        if (listAll[page].content[i] instanceof Note){ 			if ( { listAll[page].content[i] as Note}.line 			== lineClick ){ index = i; }}
	        if (listAll[page].content[i] instanceof Increase){ 		if ( { listAll[page].content[i] as Increase}.line 		== lineClick ){ index = i; }}
	        if (listAll[page].content[i] instanceof Decrease){ 		if ( { listAll[page].content[i] as Decrease}.line 		== lineClick ){ index = i; }}
	        if (listAll[page].content[i] instanceof Multiply){ 		if ( { listAll[page].content[i] as Multiply}.line 		== lineClick ){ index = i; }}
	        if (listAll[page].content[i] instanceof Divide){ 		if ( { listAll[page].content[i] as Divide}.line 			== lineClick ){ index = i; }}
	        if (listAll[page].content[i] instanceof Raise){ 		if ( { listAll[page].content[i] as Raise}.line 			== lineClick ){ index = i; }}
	        if (listAll[page].content[i] instanceof Testify){ 		if ( { listAll[page].content[i] as Testify}.line 		== lineClick ){ index = i; }}
	        if (listAll[page].content[i] instanceof Falsify){ 		if ( { listAll[page].content[i] as Falsify}.line 		== lineClick ){ index = i; }}
	        if (listAll[page].content[i] instanceof If){ 			if ( { listAll[page].content[i] as If}.line 				== lineClick ){ index = i; }}
	        if (listAll[page].content[i] instanceof While){ 		if ( { listAll[page].content[i] as While}.line 			== lineClick ){ index = i; }}
	        if (listAll[page].content[i] instanceof Set){ 			if ( { listAll[page].content[i] as Set}.line 			== lineClick ){ index = i; }}
	        if (listAll[page].content[i] instanceof EndCondition){ 	if ( { listAll[page].content[i] as EndCondition}.line 			== lineClick ){ index = i; }}
	        if (listAll[page].content[i] instanceof BreakCondition){if ( { listAll[page].content[i] as BreakCondition}.line 			== lineClick ){ index = i; }}
	        if (listAll[page].content[i] instanceof ListenToSuggestion){if ( { listAll[page].content[i] as ListenToSuggestion}.line 			== lineClick ){ index = i; }}
	        if (listAll[page].content[i] instanceof DisproveSuggestionWith){if ( { listAll[page].content[i] as DisproveSuggestionWith}.line 			== lineClick ){ index = i; }}

	    }
	    
	    if (index != -1)
	    {
	        delete listAll[page].content[index];
	    }
	    lineClick = -1;
	}

    public var lines = for (i in [0..numberOfLines])
    {
        Group
        {
            translateX: 10
            translateY: bind 10 - (20*numberOfLines*barOffsetYPct) +410*barOffsetYPct;
            content:
            [
            	TileLine{lineNumber: i}
            ]
            onMousePressed: function( e: MouseEvent): Void
            {
                println(" >> {lineClick}");
                //if (didClickTile == true){
                	lineClick = i;
                //}
                println(" ## {lineClick}");
            }

        }
        
    }

    
    var window = Group
    {
        onMousePressed:  function (e:MouseEvent):Void{}
        blocksMouse: true
        content:
        [
        	ShapeSubtract
        	{
        	    fill      : Color.web("#006699")
        	    a: [
	        	       Rectangle
	        	       {
	        	            x         : 0
	        	            y         : 0
	        	       		width     : 660
	        	            height    : 450
	        	            arcHeight : 5
	        	            arcWidth  : 5
	        	            
	        	       }
        	       ] 
        	    b: [
	        	       Rectangle
	        	       {
	        	           	x         : 10
	        	           	y         : 10
	        	       		width     : 640
	        	            height    : 430
	        	            arcHeight : 5
	        	            arcWidth  : 5
	        	       }
        	       ]
        	     
        	}
        ]
    }

    var scrollbar = Group
    {
        content:
        [
        	Rectangle //black gauge
        	{
        	    x: 630
        	    y: 10
        	    width: 20
        	    height: 430
        	    
        		onMousePressed: function(e:MouseEvent):Void
        		{
        		    isScrolling = true;
        		}
        		onMouseExited: function(e:MouseEvent):Void
        		{
        		    isScrolling = false;
        		}
        	}
        	Rectangle //scroll bar
        	{
        		x: 630
        		y: bind 30+barOffsetY
        		width: bind 20
        		height: 100
        		fill: Color.web("#002864")
        		
        		onMousePressed: function(e:MouseEvent):Void
        		{
        		    isScrolling = true;
        		}
        		
        		onMouseDragged: function(e:MouseEvent):Void
        		{
        		    isScrolling = true;
        		    barOffsetY = e.sceneY-135;
        		    if (barOffsetY < 0){ barOffsetY = 0; }
        		    if (barOffsetY > 290){ barOffsetY = 290; }
        		    barOffsetYPct = barOffsetY / 290;
        		}
        		onMouseExited: function(e:MouseEvent):Void
        		{
        		    isScrolling = false;
        		}
        	}
        	Rectangle //up arrow
        	{
        	    x: 630
        	    y: 10
        	    width: 20
        	    height: 20
        	    fill: Color.web("#003298")
        	    onMouseClicked: function(e:MouseEvent):Void
        	    {
        	        barOffsetY -= 1;
        		    if (barOffsetY < 0){ barOffsetY = 0; }
        		    if (barOffsetY > 290){ barOffsetY = 290; }
        		    barOffsetYPct = barOffsetY / 290;
        	    }
        	    
        	}
        	Rectangle //down arrow
        	{
        	    x: 630
        	    y: 420
        	    width: 20
        	    height: 20
        	    fill: Color.web("#003298")
				onMouseClicked: function(e:MouseEvent):Void
        	    {
        	        barOffsetY += 1;
        		    if (barOffsetY < 0){ barOffsetY = 0; }
        		    if (barOffsetY > 290){ barOffsetY = 290; }
        		    barOffsetYPct = barOffsetY / 290;
        	    }
        	}
        ]
    }
   
	var cover = Group
	{
	    blocksMouse: true
	    translateX: 0//-280
	    translateY: -55
	    content:
	    [
			ShapeSubtract
        	{
        	    fill      : Color.web("#1B1B1B")
        	    a: [
	        	       Rectangle
	        	       {
	        	            x         : 0
	        	            y         : 0
	        	       		width     : 960
	        	            height    : 540
	        	       }
        	       ] 
        	    b: [
	        	       Rectangle
	        	       {
	        	           	x         : 0
	        	           	y         : 55
	        	       		width     : 660
	        	            height    : 450
	        	            arcHeight : 5
	        	            arcWidth  : 5
	        	       }
        	       ]
        	     
        	}
        ]
	}
   
    public var group = Group
    {
        content: bind
        [
        	lines,
        	listAll[page],
			cover,
        	scrollbar,
			window		
        ]
    }
    
    override public function create() : Node
    {
        return group;
    }
}